/*
 * Consultar_Producto.java
 *
 * Created on 14-oct-2008, 9:10:48
 */
package investigaciones_itm.Productos;

import com.sun.data.provider.RowKey;
import com.sun.rave.faces.data.DefaultSelectItemsArray;
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import com.sun.webui.jsf.component.Body;
import com.sun.webui.jsf.component.Button;
import com.sun.webui.jsf.component.DropDown;
import com.sun.webui.jsf.component.Form;
import com.sun.webui.jsf.component.Head;
import com.sun.webui.jsf.component.Html;
import com.sun.webui.jsf.component.Label;
import com.sun.webui.jsf.component.Link;
import com.sun.webui.jsf.component.Listbox;
import com.sun.webui.jsf.component.Page;
import com.sun.webui.jsf.component.PageSeparator;
import com.sun.webui.jsf.component.PanelGroup;
import com.sun.webui.jsf.component.PanelLayout;
import com.sun.webui.jsf.component.StaticText;
import com.sun.webui.jsf.component.Tab;
import com.sun.webui.jsf.component.TabSet;
import com.sun.webui.jsf.component.Table;
import com.sun.webui.jsf.component.TableColumn;
import com.sun.webui.jsf.component.TableRowGroup;
import com.sun.webui.jsf.component.TextField;
import com.sun.webui.jsf.model.DefaultOptionsList;
import com.sun.webui.jsf.model.DefaultTableDataProvider;
import com.sun.webui.jsf.model.SingleSelectOptionsList;
import javax.faces.FacesException;
import investigaciones_itm.ApplicationBean1;
import investigaciones_itm.RequestBean1;
import investigaciones_itm.SessionBean1;
import itm.bo.administracion.IndicadoresBO;
import itm.bo.productos.ProductosBO;
import itm.bo.administracion.TipoAtributoBO;
import itm.bo.productos.AtributosBO;
import itm.vo.administracion.IndicadoresVO;
import itm.vo.administracion.TipoAtributoVO;
import itm.vo.prodructos.AtributosVO;
import java.util.ArrayList;
import java.util.List;
import javax.faces.component.UISelectItems;
import javax.faces.component.html.HtmlMessages;
import javax.faces.component.html.HtmlPanelGrid;
import javax.faces.component.html.HtmlSelectOneListbox;
import javax.faces.event.ValueChangeEvent;
import javax.faces.model.SelectItem;
import itm.base.ListaAtributos;
import itm.exception.ControlException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * <p>Page bean that corresponds to a similarly named JSP page.  This
 * class contains component definitions (and initialization code) for
 * all components that you have defined on this page, as well as
 * lifecycle methods and event handlers where you may add behavior
 * to respond to incoming events.</p>
 *
 * @author Administrador
 */
public class Parametrizacion_atributos extends AbstractPageBean {

    ProductosBO productosBO;
    AtributosBO atributosBO;
    AtributosVO atributosVO;
    private StaticText stIdTipoProducto;
    private StaticText stIdTipoAtributo;

    // <editor-fold defaultstate="collapsed" desc="Managed Component Definition">
    /**
     * <p>Automatically managed component initialization.  <strong>WARNING:</strong>
     * This method is automatically generated, so any user-specified code inserted
     * here is subject to being replaced.</p>
     */
    private void _init() throws Exception {
        dropDownEspecificoDefaultOptions.setOptions(new com.sun.webui.jsf.model.Option[]{new com.sun.webui.jsf.model.Option("", "Seleccione "), new com.sun.webui.jsf.model.Option("SI", "Si"), new com.sun.webui.jsf.model.Option("NO", "No")});
        dropDownVerificacionDefaultOptions.setOptions(new com.sun.webui.jsf.model.Option[]{new com.sun.webui.jsf.model.Option("", "Seleccione"), new com.sun.webui.jsf.model.Option("S", "Si"), new com.sun.webui.jsf.model.Option("N", "No")});
        dropDownVerificacion1DefaultOptions.setOptions(new com.sun.webui.jsf.model.Option[]{new com.sun.webui.jsf.model.Option("", "Seleccione "), new com.sun.webui.jsf.model.Option("SI", "SI"), new com.sun.webui.jsf.model.Option("NO", "NO")});
        dropDownEspecifico1DefaultOptions.setOptions(new com.sun.webui.jsf.model.Option[]{new com.sun.webui.jsf.model.Option("", "Seleccione"), new com.sun.webui.jsf.model.Option("SI", "SI"), new com.sun.webui.jsf.model.Option("NO", "NO")});
    }
    private Page page1 = new Page();

    public Page getPage1() {
        return page1;
    }

    public void setPage1(Page p) {
        this.page1 = p;
    }
    private Html html1 = new Html();

    public Html getHtml1() {
        return html1;
    }

    public void setHtml1(Html h) {
        this.html1 = h;
    }
    private Head head1 = new Head();

    public Head getHead1() {
        return head1;
    }

    public void setHead1(Head h) {
        this.head1 = h;
    }
    private Link link1 = new Link();

    public Link getLink1() {
        return link1;
    }

    public void setLink1(Link l) {
        this.link1 = l;
    }
    private Body body1 = new Body();

    public Body getBody1() {
        return body1;
    }

    public void setBody1(Body b) {
        this.body1 = b;
    }
    private Form form1 = new Form();

    public Form getForm1() {
        return form1;
    }

    public void setForm1(Form f) {
        this.form1 = f;
    }
    private PanelGroup groupPanel1 = new PanelGroup();

    public PanelGroup getGroupPanel1() {
        return groupPanel1;
    }

    public void setGroupPanel1(PanelGroup pg) {
        this.groupPanel1 = pg;
    }
    private TabSet tabSet1 = new TabSet();

    public TabSet getTabSet1() {
        return tabSet1;
    }

    public void setTabSet1(TabSet ts) {
        this.tabSet1 = ts;
    }
    private Tab tab1 = new Tab();

    public Tab getTab1() {
        return tab1;
    }

    public void setTab1(Tab t) {
        this.tab1 = t;
    }
    private PanelLayout layoutPanel1 = new PanelLayout();

    public PanelLayout getLayoutPanel1() {
        return layoutPanel1;
    }

    public void setLayoutPanel1(PanelLayout pl) {
        this.layoutPanel1 = pl;
    }
    private Label label1 = new Label();

    public Label getLabel1() {
        return label1;
    }

    public void setLabel1(Label l) {
        this.label1 = l;
    }
    private TextField areaNombreAtributo = new TextField();

    public TextField getAreaNombreAtributo() {
        return areaNombreAtributo;
    }

    public void setAreaNombreAtributo(TextField tf) {
        this.areaNombreAtributo = tf;
    }
    private Label label2 = new Label();

    public Label getLabel2() {
        return label2;
    }

    public void setLabel2(Label l) {
        this.label2 = l;
    }
    private Label label3 = new Label();

    public Label getLabel3() {
        return label3;
    }

    public void setLabel3(Label l) {
        this.label3 = l;
    }
    private TextField areaLongitud = new TextField();

    public TextField getAreaLongitud() {
        return areaLongitud;
    }

    public void setAreaLongitud(TextField tf) {
        this.areaLongitud = tf;
    }
    private Label label4 = new Label();

    public Label getLabel4() {
        return label4;
    }

    public void setLabel4(Label l) {
        this.label4 = l;
    }
    private DropDown dropDownEspecifico = new DropDown();

    public DropDown getDropDownEspecifico() {
        return dropDownEspecifico;
    }

    public void setDropDownEspecifico(DropDown dd) {
        this.dropDownEspecifico = dd;
    }
    private SingleSelectOptionsList dropDownEspecificoDefaultOptions = new SingleSelectOptionsList();

    public SingleSelectOptionsList getDropDownEspecificoDefaultOptions() {
        return dropDownEspecificoDefaultOptions;
    }

    public void setDropDownEspecificoDefaultOptions(SingleSelectOptionsList ssol) {
        this.dropDownEspecificoDefaultOptions = ssol;
    }
    private Label label5 = new Label();

    public Label getLabel5() {
        return label5;
    }

    public void setLabel5(Label l) {
        this.label5 = l;
    }
    private Label label6 = new Label();

    public Label getLabel6() {
        return label6;
    }

    public void setLabel6(Label l) {
        this.label6 = l;
    }
    private DropDown dropDownVerificacion = new DropDown();

    public DropDown getDropDownVerificacion() {
        return dropDownVerificacion;
    }

    public void setDropDownVerificacion(DropDown dd) {
        this.dropDownVerificacion = dd;
    }
    private SingleSelectOptionsList dropDownVerificacionDefaultOptions = new SingleSelectOptionsList();

    public SingleSelectOptionsList getDropDownVerificacionDefaultOptions() {
        return dropDownVerificacionDefaultOptions;
    }

    public void setDropDownVerificacionDefaultOptions(SingleSelectOptionsList ssol) {
        this.dropDownVerificacionDefaultOptions = ssol;
    }
    private Button button1Guardar = new Button();

    public Button getButton1Guardar() {
        return button1Guardar;
    }

    public void setButton1Guardar(Button b) {
        this.button1Guardar = b;
    }
    private Button buttonCancelar = new Button();

    public Button getButtonCancelar() {
        return buttonCancelar;
    }

    public void setButtonCancelar(Button b) {
        this.buttonCancelar = b;
    }
    private HtmlSelectOneListbox listbox1TipoAtributo = new HtmlSelectOneListbox();

    public HtmlSelectOneListbox getListbox1TipoAtributo() {

        listbox1TipoAtributo = new HtmlSelectOneListbox();
        String idTipoProducto;
        String nombreTipoProducto;

        TipoAtributoBO tipoAtributoBO = new TipoAtributoBO();
        List<TipoAtributoVO> listaTipoAtributo = new ArrayList<TipoAtributoVO>();
        List collection = new ArrayList();
        collection.add(new SelectItem(0, "-Seleccione un tipo de Atributo-"));
        try {
            listaTipoAtributo = tipoAtributoBO.listarTipoAtributo();

            for (int i = 0; i < listaTipoAtributo.size(); i++) {
                idTipoProducto = listaTipoAtributo.get(i).getIdTipoAtributo();
                nombreTipoProducto = listaTipoAtributo.get(i).getNombreTipoAtributo();

                collection.add(new SelectItem(idTipoProducto, nombreTipoProducto));
            } // end for
            UISelectItems listaMenu = new UISelectItems();
            listaMenu.setValue(collection);
            listbox1TipoAtributo.getChildren().add(listaMenu);
        } catch (Exception e) {
            e.getStackTrace();
        }
        return listbox1TipoAtributo;
    }

    public void setListbox1TipoAtributo(HtmlSelectOneListbox hsol) {
        this.listbox1TipoAtributo = hsol;
    }
    private UISelectItems listbox1SelectItems = new UISelectItems();

    public UISelectItems getListbox1SelectItems() {
        return listbox1SelectItems;
    }

    public void setListbox1SelectItems(UISelectItems uisi) {
        this.listbox1SelectItems = uisi;
    }
    private HtmlSelectOneListbox listbox1TipoProducto = new HtmlSelectOneListbox();

    public HtmlSelectOneListbox getListbox1TipoProducto() {

        listbox1TipoProducto = new HtmlSelectOneListbox();

        listbox1TipoProducto = new HtmlSelectOneListbox();
        String idTipoProducto;
        String nombreTipoProducto;

        IndicadoresBO indicadoresBO = new IndicadoresBO();
        List<IndicadoresVO> listatipoProducto = new ArrayList<IndicadoresVO>();
        List collection = new ArrayList();
        collection.add(new SelectItem(0, "-Seleccione un tipo de Producto-"));
        try {
            listatipoProducto = indicadoresBO.listartipoProducto();

            for (int i = 0; i < listatipoProducto.size(); i++) {
                idTipoProducto = listatipoProducto.get(i).getIdTipoProducto();
                nombreTipoProducto = listatipoProducto.get(i).getNombreTipoProducto();

                collection.add(new SelectItem(idTipoProducto, nombreTipoProducto));

            } // end for
            UISelectItems listaMenu = new UISelectItems();
            listaMenu.setValue(collection);
            listbox1TipoProducto.getChildren().add(listaMenu);
        } catch (Exception e) {
            e.getStackTrace();
        }

        return listbox1TipoProducto;
    }

    public void setListbox1TipoProducto(HtmlSelectOneListbox hsol) {
        this.listbox1TipoProducto = hsol;
    }
    private DefaultSelectItemsArray listbox1DefaultItems1 = new DefaultSelectItemsArray();

    public DefaultSelectItemsArray getListbox1DefaultItems1() {
        return listbox1DefaultItems1;
    }

    public void setListbox1DefaultItems1(DefaultSelectItemsArray dsia) {
        this.listbox1DefaultItems1 = dsia;
    }
    private UISelectItems listbox1SelectItems1 = new UISelectItems();

    public UISelectItems getListbox1SelectItems1() {
        return listbox1SelectItems1;
    }

    public void setListbox1SelectItems1(UISelectItems uisi) {
        this.listbox1SelectItems1 = uisi;
    }
    private DefaultSelectItemsArray listbox1TipoAtributoDefaultItems = new DefaultSelectItemsArray();

    public DefaultSelectItemsArray getListbox1TipoAtributoDefaultItems() {
        return listbox1TipoAtributoDefaultItems;
    }

    public void setListbox1TipoAtributoDefaultItems(DefaultSelectItemsArray dsia) {
        this.listbox1TipoAtributoDefaultItems = dsia;
    }
    private DefaultSelectItemsArray listbox1DefaultItems2 = new DefaultSelectItemsArray();

    public DefaultSelectItemsArray getListbox1DefaultItems2() {
        return listbox1DefaultItems2;
    }

    public void setListbox1DefaultItems2(DefaultSelectItemsArray dsia) {
        this.listbox1DefaultItems2 = dsia;
    }
    private DefaultSelectItemsArray listbox1DefaultItems3 = new DefaultSelectItemsArray();

    public DefaultSelectItemsArray getListbox1DefaultItems3() {
        return listbox1DefaultItems3;
    }

    public void setListbox1DefaultItems3(DefaultSelectItemsArray dsia) {
        this.listbox1DefaultItems3 = dsia;
    }
    private Label labelespecifico = new Label();

    public Label getLabelespecifico() {
        return labelespecifico;
    }

    public void setLabelespecifico(Label l) {
        this.labelespecifico = l;
    }
    private Label labelIndicador = new Label();

    public Label getLabelIndicador() {
        return labelIndicador;
    }

    public void setLabelIndicador(Label l) {
        this.labelIndicador = l;
    }
    private HtmlMessages messageList1 = new HtmlMessages();

    public HtmlMessages getMessageList1() {
        return messageList1;
    }

    public void setMessageList1(HtmlMessages hm) {
        this.messageList1 = hm;
    }
    private Tab tabConsultar = new Tab();

    public Tab getTabConsultar() {
        return tabConsultar;
    }

    public void setTabConsultar(Tab t) {
        this.tabConsultar = t;
    }
    private PanelLayout layoutPanel2 = new PanelLayout();

    public PanelLayout getLayoutPanel2() {
        return layoutPanel2;
    }

    public void setLayoutPanel2(PanelLayout pl) {
        this.layoutPanel2 = pl;
    }
    private Tab tabModifi = new Tab();

    public Tab getTabModifi() {
        return tabModifi;
    }

    public void setTabModifi(Tab t) {
        this.tabModifi = t;
    }
    private PanelLayout layoutPanel3 = new PanelLayout();

    public PanelLayout getLayoutPanel3() {
        return layoutPanel3;
    }

    public void setLayoutPanel3(PanelLayout pl) {
        this.layoutPanel3 = pl;
    }
    private Table table1 = new Table();

    public Table getTable1() {
        return table1;
    }

    public void setTable1(Table t) {
        this.table1 = t;
    }
    private TableRowGroup tableRowGroup1 = new TableRowGroup();

    public TableRowGroup getTableRowGroup1() {
        return tableRowGroup1;
    }

    public void setTableRowGroup1(TableRowGroup trg) {
        this.tableRowGroup1 = trg;
    }
    private TableColumn tableColumn2 = new TableColumn();

    public TableColumn getTableColumn2() {
        return tableColumn2;
    }

    public void setTableColumn2(TableColumn tc) {
        this.tableColumn2 = tc;
    }
    private StaticText staticText2 = new StaticText();

    public StaticText getStaticText2() {
        return staticText2;
    }

    public void setStaticText2(StaticText st) {
        this.staticText2 = st;
    }
    private TableColumn tableColumn10 = new TableColumn();

    public TableColumn getTableColumn10() {
        return tableColumn10;
    }

    public void setTableColumn10(TableColumn tc) {
        this.tableColumn10 = tc;
    }
    private StaticText staticText10 = new StaticText();

    public StaticText getStaticText10() {
        return staticText10;
    }

    public void setStaticText10(StaticText st) {
        this.staticText10 = st;
    }
    private TableColumn tableColumn1 = new TableColumn();

    public TableColumn getTableColumn1() {
        return tableColumn1;
    }

    public void setTableColumn1(TableColumn tc) {
        this.tableColumn1 = tc;
    }
    private StaticText staticText1 = new StaticText();

    public StaticText getStaticText1() {
        return staticText1;
    }

    public void setStaticText1(StaticText st) {
        this.staticText1 = st;
    }
    private TableColumn tableColumn3 = new TableColumn();

    public TableColumn getTableColumn3() {
        return tableColumn3;
    }

    public void setTableColumn3(TableColumn tc) {
        this.tableColumn3 = tc;
    }
    private StaticText staticText3 = new StaticText();

    public StaticText getStaticText3() {
        return staticText3;
    }

    public void setStaticText3(StaticText st) {
        this.staticText3 = st;
    }
    private TableColumn tableColumn4 = new TableColumn();

    public TableColumn getTableColumn4() {
        return tableColumn4;
    }

    public void setTableColumn4(TableColumn tc) {
        this.tableColumn4 = tc;
    }
    private StaticText staticText4 = new StaticText();

    public StaticText getStaticText4() {
        return staticText4;
    }

    public void setStaticText4(StaticText st) {
        this.staticText4 = st;
    }
    private HtmlSelectOneListbox listbox1TipoAtributo1 = new HtmlSelectOneListbox();

    public HtmlSelectOneListbox getListbox1TipoAtributo1() {

        listbox1TipoAtributo1 = new HtmlSelectOneListbox();
        String idTipoProducto;
        String nombreTipoProducto;

        TipoAtributoBO tipoAtributoBO = new TipoAtributoBO();
        List<TipoAtributoVO> listaTipoAtributo = new ArrayList<TipoAtributoVO>();
        List collection = new ArrayList();
        collection.add(new SelectItem(0, "-Seleccione un tipo de Producto-"));
        try {
            listaTipoAtributo = tipoAtributoBO.listarTipoAtributo();

            for (int i = 0; i < listaTipoAtributo.size(); i++) {
                idTipoProducto = listaTipoAtributo.get(i).getIdTipoAtributo();
                nombreTipoProducto = listaTipoAtributo.get(i).getNombreTipoAtributo();

                collection.add(new SelectItem(idTipoProducto, nombreTipoProducto));
            } // end for
            UISelectItems listaMenu = new UISelectItems();
            listaMenu.setValue(collection);
            listbox1TipoAtributo1.getChildren().add(listaMenu);
        } catch (Exception e) {
            e.getStackTrace();
        }
        return listbox1TipoAtributo1;
    }

    public void setListbox1TipoAtributo1(HtmlSelectOneListbox hsol) {
        this.listbox1TipoAtributo1 = hsol;
    }
    private Label label7 = new Label();

    public Label getLabel7() {
        return label7;
    }

    public void setLabel7(Label l) {
        this.label7 = l;
    }
    private Label label8 = new Label();

    public Label getLabel8() {
        return label8;
    }

    public void setLabel8(Label l) {
        this.label8 = l;
    }
    private TextField areaNombreAtributo1 = new TextField();

    public TextField getAreaNombreAtributo1() {
        return areaNombreAtributo1;
    }

    public void setAreaNombreAtributo1(TextField tf) {
        this.areaNombreAtributo1 = tf;
    }
    private Label label9 = new Label();

    public Label getLabel9() {
        return label9;
    }

    public void setLabel9(Label l) {
        this.label9 = l;
    }
    private Label label10 = new Label();

    public Label getLabel10() {
        return label10;
    }

    public void setLabel10(Label l) {
        this.label10 = l;
    }
    private Label label11 = new Label();

    public Label getLabel11() {
        return label11;
    }

    public void setLabel11(Label l) {
        this.label11 = l;
    }
    private DropDown dropDownVerificacion1 = new DropDown();

    public DropDown getDropDownVerificacion1() {
        return dropDownVerificacion1;
    }

    public void setDropDownVerificacion1(DropDown dd) {
        this.dropDownVerificacion1 = dd;
    }
    private DropDown dropDownEspecifico1 = new DropDown();

    public DropDown getDropDownEspecifico1() {
        return dropDownEspecifico1;
    }

    public void setDropDownEspecifico1(DropDown dd) {
        this.dropDownEspecifico1 = dd;
    }
    private TextField areaLongitud1 = new TextField();

    public TextField getAreaLongitud1() {
        return areaLongitud1;
    }

    public void setAreaLongitud1(TextField tf) {
        this.areaLongitud1 = tf;
    }
    private SingleSelectOptionsList dropDownVerificacion1DefaultOptions = new SingleSelectOptionsList();

    public SingleSelectOptionsList getDropDownVerificacion1DefaultOptions() {
        return dropDownVerificacion1DefaultOptions;
    }

    public void setDropDownVerificacion1DefaultOptions(SingleSelectOptionsList ssol) {
        this.dropDownVerificacion1DefaultOptions = ssol;
    }
    private SingleSelectOptionsList dropDownEspecifico1DefaultOptions = new SingleSelectOptionsList();

    public SingleSelectOptionsList getDropDownEspecifico1DefaultOptions() {
        return dropDownEspecifico1DefaultOptions;
    }

    public void setDropDownEspecifico1DefaultOptions(SingleSelectOptionsList ssol) {
        this.dropDownEspecifico1DefaultOptions = ssol;
    }
    private HtmlMessages messageList3 = new HtmlMessages();

    public HtmlMessages getMessageList3() {
        return messageList3;
    }

    public void setMessageList3(HtmlMessages hm) {
        this.messageList3 = hm;
    }
    private Label labelIdAtributo = new Label();

    public Label getLabelIdAtributo() {
        return labelIdAtributo;
    }

    public void setLabelIdAtributo(Label l) {
        this.labelIdAtributo = l;
    }
    private TableColumn tableColumn5 = new TableColumn();

    public TableColumn getTableColumn5() {
        return tableColumn5;
    }

    public void setTableColumn5(TableColumn tc) {
        this.tableColumn5 = tc;
    }
    private Button buttonModificar = new Button();

    public Button getButtonModificar() {
        return buttonModificar;
    }

    public void setButtonModificar(Button b) {
        this.buttonModificar = b;
    }
    private Button buttonEliminar = new Button();

    public Button getButtonEliminar() {
        return buttonEliminar;
    }

    public void setButtonEliminar(Button b) {
        this.buttonEliminar = b;
    }
    private HtmlMessages messageList2 = new HtmlMessages();

    public HtmlMessages getMessageList2() {
        return messageList2;
    }

    public void setMessageList2(HtmlMessages hm) {
        this.messageList2 = hm;
    }
    private Button buttonGuardarMdodifi = new Button();

    public Button getButtonGuardarMdodifi() {
        return buttonGuardarMdodifi;
    }

    public void setButtonGuardarMdodifi(Button b) {
        this.buttonGuardarMdodifi = b;
    }
    private TableColumn tableColumn6 = new TableColumn();

    public TableColumn getTableColumn6() {
        return tableColumn6;
    }

    public void setTableColumn6(TableColumn tc) {
        this.tableColumn6 = tc;
    }
    private StaticText staticText5 = new StaticText();

    public StaticText getStaticText5() {
        return staticText5;
    }

    public void setStaticText5(StaticText st) {
        this.staticText5 = st;
    }
    private TableColumn tableColumn7 = new TableColumn();

    public TableColumn getTableColumn7() {
        return tableColumn7;
    }

    public void setTableColumn7(TableColumn tc) {
        this.tableColumn7 = tc;
    }
    private StaticText staticText6 = new StaticText();

    public StaticText getStaticText6() {
        return staticText6;
    }

    public void setStaticText6(StaticText st) {
        this.staticText6 = st;
    }
    private Button button1 = new Button();

    public Button getButton1() {
        return button1;
    }

    public void setButton1(Button b) {
        this.button1 = b;
    }
    private HtmlSelectOneListbox listbox1TipoProducto1 = new HtmlSelectOneListbox();

    public HtmlSelectOneListbox getListbox1TipoProducto1() {

        listbox1TipoProducto1 = new HtmlSelectOneListbox();
        String idTipoProducto;
        String nombreTipoProducto;

        IndicadoresBO indicadoresBO = new IndicadoresBO();
        List<IndicadoresVO> listatipoProducto = new ArrayList<IndicadoresVO>();
        List collection = new ArrayList();
        collection.add(new SelectItem(0, "-Seleccione un tipo de Producto-"));
        try {
            listatipoProducto = indicadoresBO.listartipoProducto();

            for (int i = 0; i < listatipoProducto.size(); i++) {
                idTipoProducto = listatipoProducto.get(i).getIdTipoProducto();
                nombreTipoProducto = listatipoProducto.get(i).getNombreTipoProducto();

                collection.add(new SelectItem(idTipoProducto, nombreTipoProducto));

            } // end for
            UISelectItems listaMenu = new UISelectItems();
            listaMenu.setValue(collection);
            listbox1TipoProducto1.getChildren().add(listaMenu);
        } catch (Exception e) {
            e.getStackTrace();
        }


        return listbox1TipoProducto1;
    }

    public void setListbox1TipoProducto1(HtmlSelectOneListbox hsol) {
        this.listbox1TipoProducto1 = hsol;
    }
    private Label label13 = new Label();

    public Label getLabel13() {
        return label13;
    }

    public void setLabel13(Label l) {
        this.label13 = l;
    }
    private HtmlPanelGrid gridPanelDatos = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanelDatos() {
        return gridPanelDatos;
    }

    public void setGridPanelDatos(HtmlPanelGrid hpg) {
        this.gridPanelDatos = hpg;
    }
    private HtmlPanelGrid gridPanelBotones = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanelBotones() {
        return gridPanelBotones;
    }

    public void setGridPanelBotones(HtmlPanelGrid hpg) {
        this.gridPanelBotones = hpg;
    }
    private HtmlPanelGrid gridPanelPrincipal = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanelPrincipal() {
        return gridPanelPrincipal;
    }

    public void setGridPanelPrincipal(HtmlPanelGrid hpg) {
        this.gridPanelPrincipal = hpg;
    }
    private HtmlPanelGrid gridPanelPrincipal1 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanelPrincipal1() {
        return gridPanelPrincipal1;
    }

    public void setGridPanelPrincipal1(HtmlPanelGrid hpg) {
        this.gridPanelPrincipal1 = hpg;
    }
    private HtmlPanelGrid gridPanelDatos1 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanelDatos1() {
        return gridPanelDatos1;
    }

    public void setGridPanelDatos1(HtmlPanelGrid hpg) {
        this.gridPanelDatos1 = hpg;
    }
    private HtmlPanelGrid gridPanelBotones1 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanelBotones1() {
        return gridPanelBotones1;
    }

    public void setGridPanelBotones1(HtmlPanelGrid hpg) {
        this.gridPanelBotones1 = hpg;
    }
    private HtmlPanelGrid gridPanelListBox = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanelListBox() {
        return gridPanelListBox;
    }

    public void setGridPanelListBox(HtmlPanelGrid hpg) {
        this.gridPanelListBox = hpg;
    }

    // </editor-fold>
    /**
     * <p>Construct a new Page bean instance.</p>
     */
    public Parametrizacion_atributos() {
    }

    /**
     * <p>Callback method that is called whenever a page is navigated to,
     * either directly via a URL, or indirectly via page navigation.
     * Customize this method to acquire resources that will be needed
     * for event handlers and lifecycle methods, whether or not this
     * page is performing post back processing.</p>
     * 
     * <p>Note that, if the current request is a postback, the property
     * values of the components do <strong>not</strong> represent any
     * values submitted with this request.  Instead, they represent the
     * property values that were saved for this view when it was rendered.</p>
     */
    @Override
    public void init() {
        // Perform initializations inherited from our superclass
        super.init();
        // Perform application initialization that must complete
        // *before* managed components are initialized
        // TODO - add your own initialiation code here

        // <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
        // Initialize automatically managed components
        // *Note* - this logic should NOT be modified
        try {
            _init();
        } catch (Exception e) {
            log("Consultar_Producto Initialization Failure", e);
            throw e instanceof FacesException ? (FacesException) e : new FacesException(e);
        }

    // </editor-fold>
    // Perform application initialization that must complete
    // *after* managed components are initialized
    // TODO - add your own initialization code here
    }

    /**
     * <p>Callback method that is called after the component tree has been
     * restored, but before any event processing takes place.  This method
     * will <strong>only</strong> be called on a postback request that
     * is processing a form submit.  Customize this method to allocate
     * resources that will be required in your event handlers.</p>
     */
    @Override
    public void preprocess() {
    }

    /**
     * <p>Callback method that is called just before rendering takes place.
     * This method will <strong>only</strong> be called for the page that
     * will actually be rendered (and not, for example, on a page that
     * handled a postback and then navigated to a different page).  Customize
     * this method to allocate resources that will be required for rendering
     * this page.</p>
     */
    @Override
    public void prerender() {

        if (dropDownEspecifico.getSelected() == null) {
            dropDownEspecifico.setSelected("999");
        //  textArea1.setValue("999");
        }



    }

    /**
     * <p>Callback method that is called after rendering is completed for
     * this request, if <code>init()</code> was called (regardless of whether
     * or not this was the page that was actually rendered).  Customize this
     * method to release resources acquired in the <code>init()</code>,
     * <code>preprocess()</code>, or <code>prerender()</code> methods (or
     * acquired during execution of an event handler).</p>
     */
    @Override
    public void destroy() {
    }

    /**
     * <p>Return a reference to the scoped data bean.</p>
     *
     * @return reference to the scoped data bean
     */
    protected ApplicationBean1 getApplicationBean1() {
        return (ApplicationBean1) getBean("ApplicationBean1");
    }

    /**
     * <p>Return a reference to the scoped data bean.</p>
     *
     * @return reference to the scoped data bean
     */
    protected RequestBean1 getRequestBean1() {
        return (RequestBean1) getBean("RequestBean1");
    }

    /**
     * <p>Return a reference to the scoped data bean.</p>
     *
     * @return reference to the scoped data bean
     */
    protected SessionBean1 getSessionBean1() {
        return (SessionBean1) getBean("SessionBean1");
    }

    public String tab1_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        return null;
    }

    public void dropDownEspecifico_processValueChange(ValueChangeEvent event) {
        String seleccionado = "";

        seleccionado = (String) event.getNewValue();

        if (seleccionado.equals("SI")) {
            label5.setRendered(true);
            label13.setVisible(true);
            listbox1TipoProducto.setRendered(true);
            listbox1TipoProducto1.setRendered(true);

        }
        if (seleccionado.equals("NO")) {
            listbox1TipoProducto.setValue("");
            label5.setRendered(false);
            label13.setVisible(false);
            listbox1TipoProducto.setRendered(false);
            listbox1TipoProducto1.setRendered(false);

        }

    }

    public String button1Guardar_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.


        String resultadoParticipantes = "";
        String resultado = null;
        String nombreAtributo = "", idTipoAtributo = "", longitud = "", especifico = "", idTipoProducto = "", indicador = "";

        try {
            AtributosVO atributosVO = new AtributosVO();
            ProductosBO productosBO = new ProductosBO();



            idTipoAtributo = (String) listbox1TipoAtributo.getValue();
            longitud = (String) areaLongitud.getValue();
            labelespecifico.setText(dropDownEspecifico.getSelected().toString());
            especifico = (String) labelespecifico.getValue();
            idTipoProducto = (String) listbox1TipoProducto.getValue();
            nombreAtributo = (String) areaNombreAtributo.getValue();
            labelIndicador.setText(dropDownVerificacion.getSelected().toString());
            indicador = (String) labelIndicador.getValue();

            if (nombreAtributo == null || nombreAtributo.equals("")) {
                error("Por favor digíte el nombre del atributo.");
                return null;
            }
            if (idTipoAtributo == null || idTipoAtributo.equals("0")) {
                error("Por favor seleccione el tipo del Atributo");
                return null;
            }
            if (longitud == null || longitud.equals("")) {
                error("Por favor digíte la longitud del atributo");
                return null;
            } else {
                if (!esNumericoRegex(longitud)) {
                    error("Longitud solo permite valores numéricos");
                    return null;
                }
            }
            if (especifico == null || especifico.equals("")) {
                error("Por favor seleccione si el atributo es especifico o no.");
                return null;
            } else {
                if (especifico.equals("SI")) {
                    if (idTipoProducto == null || idTipoProducto.equals("0")) {
                        error("Por favor seleccione el tipo de producto asociado");
                        return null;
                    }
                }
            }
            if (indicador == null || indicador.equals("")) {
                error("Por favor seleccione si el atributo es un indicador o no.");
                return null;
            }
            atributosVO.setIdTipoProducto(idTipoProducto);
            atributosVO.setLongitud(longitud);
            atributosVO.setEspecifico(especifico);
            atributosVO.setIdTipoAtributo(idTipoAtributo);
            atributosVO.setNombreAtributo(nombreAtributo);
            atributosVO.setIndicadorVerificacion(indicador);
            resultado = productosBO.crearAtributosProducto(atributosVO);
            info(resultado);
            limpiar();
        } catch (Exception e) {
            e.printStackTrace();
            error("Error al ingresar el evento.");
        }


        return null;
    }

    private boolean esNumericoRegex(String numero) {
        Pattern p = Pattern.compile("[0-9]+");
        Matcher m = p.matcher(numero);
        return m.matches();
    }

    public String tabConsultar_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        List<AtributosVO> listaAtributo = new ArrayList<AtributosVO>();



        try {
            atributosVO = new AtributosVO();
            productosBO = new ProductosBO();
            listaAtributo = new ArrayList<AtributosVO>();


            listaAtributo = productosBO.listarAtributos(atributosVO);
            getSessionBean1().addListaAtributos(listaAtributo);

        } catch (Exception e) {
            error("Error al ingresar el Atributo.");
        }
        return "OK";

    }

    public String tabModifi_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        return null;
    }

    public String buttonModificar_action() {
        labelIdAtributo.setVisible(true);
       
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        String idAtribu = "", nombreAtri = "", tipoAtri = "", longitud = "",
                especifico = "", nombreTipoPro = "", Indica = "", idPro = "", idAtri = "";
        tabModifi.setRendered(true);
        try {

            idAtribu = (String) staticText2.getValue();

            labelIdAtributo.setValue(idAtribu);
            tabSet1.setSelected(tabModifi.getId().toString());
            nombreAtri = (String) staticText10.getValue();
            
            areaNombreAtributo1.setText(nombreAtri);
            tipoAtri = (String) staticText1.getValue();
            idAtri = (String) stIdTipoAtributo.getValue();

           
            listbox1TipoAtributo1.setValue(idAtri);
            longitud = (String) staticText4.getValue();
           
            areaLongitud1.setText(longitud);
            especifico = (String) staticText5.getValue();
           
            dropDownEspecifico1.setValue(especifico);
            if (especifico.equals("SI")) {
                nombreTipoPro = (String) staticText3.getValue();
                idPro = (String) stIdTipoProducto.getValue();
              
                listbox1TipoProducto1.setValue(idPro);
                listbox1TipoProducto1.setRendered(true);
                label13.setVisible(true);
            } else {
                listbox1TipoProducto1.setRendered(false);
                label13.setVisible(false);
            }
            Indica = (String) staticText6.getValue();
          
            if(Indica.equals("S ")){
            dropDownVerificacion1.setValue("SI");
            }else{
            dropDownVerificacion1.setValue("NO");
            }
            
        } catch (Exception e) {
        }

        return null;
    }

    public String buttonEliminar_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.

        String aux = "";

        RowKey rowToRemove = tableRowGroup1.getRowKey();

        ListaAtributos listaAtri = getSessionBean1().getListaDatosAtributos();
        String idAtributo = "", mostrar = "";

        try {
            atributosVO = new AtributosVO();
            atributosBO = new AtributosBO();
            idAtributo = (String) staticText2.getValue();


            atributosVO.setIdAtributoProducto(idAtributo);
            mostrar = atributosBO.eliminarTipoEvento(atributosVO);
            if (!mostrar.equals("EL Atributo no se puede eliminar porque tiene asociado un producto")) {
                info(mostrar);
                listaAtri.removeRow(rowToRemove);
                listaAtri.commitChanges();
            } else {
                error(mostrar);
            }

        } catch (ControlException ce) {
            error("Error al eliminar el tipo de evento.");
            ce.printStackTrace();
            listaAtri.revertChanges();
        }
        return null;
    }

    public String buttonGuardarMdodifi_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.

        String resultadoParticipantes = "";
        String resultado = null;
        String nombreAtributo = "", idTipoAtributo = "", longitud = "", especifico = "", idTipoProducto = "", indicador = "";
        String idAtribu = "";
        try {
            AtributosVO atributosVO = new AtributosVO();
            ProductosBO productosBO = new ProductosBO();

            idTipoAtributo = (String) listbox1TipoAtributo1.getValue();
            longitud = (String) areaLongitud1.getValue();
            labelespecifico.setText(dropDownEspecifico1.getSelected().toString());

            especifico = (String) labelespecifico.getValue();
            if (especifico.equals("NO")) {
                idTipoProducto = null;
            } else {
                idTipoProducto = (String) listbox1TipoProducto1.getValue();
            }
            nombreAtributo = (String) areaNombreAtributo1.getValue();
            labelIndicador.setText(dropDownVerificacion1.getSelected().toString());
            indicador = (String) labelIndicador.getValue();
            idAtribu = (String) labelIdAtributo.getValue();


            if (longitud == null || longitud.equals("")) {
                error("Por favor digite la longitud");
                return null;
            }
            if (idTipoAtributo == null || idTipoAtributo.equals("")) {
                error("Por favor seleccione el tipo del Atributo");
                return null;
            }
            if (nombreAtributo == null || nombreAtributo.equals("")) {
                error("Por favor digíte el nombre del atributo.");
                return null;
            }

            atributosVO.setIdAtributoProducto(idAtribu);
            atributosVO.setIdTipoProducto(idTipoProducto);
            atributosVO.setLongitud(longitud);
            atributosVO.setEspecifico(especifico);
            atributosVO.setIdTipoAtributo(idTipoAtributo);
            atributosVO.setNombreAtributo(nombreAtributo);
            atributosVO.setIndicadorVerificacion(indicador);
            resultado = productosBO.modificarAtributosProducto(atributosVO);
            info(resultado);
            limpiar();

        } catch (Exception e) {
            error("Error al ingresar el evento.");
        }


        return null;
    }

    public void limpiar() {

        areaNombreAtributo.setValue("");
        areaNombreAtributo1.setValue("");
        areaLongitud.setValue("");
        listbox1TipoAtributo.setValue("");
        listbox1TipoAtributo.setValue("");
        listbox1TipoProducto.setValue("");
        dropDownEspecifico.setValue("");
        dropDownEspecifico1.setValue("");
        dropDownVerificacion.setValue("");
        dropDownVerificacion1.setValue("");
        areaLongitud1.setValue("");

        labelIdAtributo.setVisible(false);
       


    }

    public String buttonCancelar_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.

        return "consultarProducto";
    }

    public String button1_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        tabSet1.setSelected(tab1.getId().toString());
        return null;
    }

    public StaticText getStIdTipoAtributo() {
        return stIdTipoAtributo;
    }

    public void setStIdTipoAtributo(StaticText stIdTipoAtributo) {
        this.stIdTipoAtributo = stIdTipoAtributo;
    }

    public StaticText getStIdTipoProducto() {
        return stIdTipoProducto;
    }

    public void setStIdTipoProducto(StaticText stIdTipoProducto) {
        this.stIdTipoProducto = stIdTipoProducto;
    }
}

